package com.shrct.businessprocess.organization;

import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.RCOrganizationService;
import com.shrct.businessprocess.organization.RCRoleAssignment;
import edu.fudan.langlab.domain.organization.Party;
import edu.fudan.langlab.domain.organization.SingleValuedRoleContributor;
import java.util.Collection;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component(value = "RCCTOProvider")
@SuppressWarnings("all")
public class RCCTOProvider implements SingleValuedRoleContributor {
  @Autowired
  private RCOrganizationService orgainzationService;
  
  public Party getParty() {
    String _roleId = this.getRoleId();
    Collection<RCRoleAssignment> _roleAssignment = this.orgainzationService.getRoleAssignment(_roleId);
    final Function1<RCRoleAssignment,RCEmployee> _function = new Function1<RCRoleAssignment,RCEmployee>() {
        public RCEmployee apply(final RCRoleAssignment it) {
          RCEmployee _employee = it.getEmployee();
          return _employee;
        }
      };
    Iterable<RCEmployee> _map = IterableExtensions.<RCRoleAssignment, RCEmployee>map(_roleAssignment, _function);
    final Function1<RCEmployee,Boolean> _function_1 = new Function1<RCEmployee,Boolean>() {
        public Boolean apply(final RCEmployee it) {
          return Boolean.valueOf(true);
        }
      };
    RCEmployee _findFirst = IterableExtensions.<RCEmployee>findFirst(_map, _function_1);
    return _findFirst;
  }
  
  public String getDescription() {
    return "\u6280\u672F\u603B\u76D1";
  }
  
  public String getRoleId() {
    return "CTO";
  }
}
